package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCFaultReport;
import com.shrct.businessprocess.customerservice.RCFaultReportLevelUpgradeService;
import com.shrct.businessprocess.customerservice.RCFaultStatus;
import edu.fudan.mylang.pf.BaseService;
import edu.fudan.mylang.pf.IGenericQuery;
import java.util.Collection;
import org.eclipse.xtext.xbase.lib.InputOutput;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.stereotype.Service;

@Service("com.shrct.businessprocess.customerservice.RCFaultReportLevelUpgradeService")
public class RCFaultReportLevelUpgradeServiceImpl extends BaseService implements RCFaultReportLevelUpgradeService {
  public void check4Upgrade() {
    final RCFaultStatus rmaState = RCFaultStatus.waiting4rma;
    final RCFaultStatus pendingState = RCFaultStatus.pending;
    final RCFaultStatus finishState = RCFaultStatus.finished;
    InputOutput.<String>println("perform check4Upgrade");
    IGenericQuery<RCFaultReport> query=getObjectFactory().createGenericQuery(RCFaultReport.class,"select e from com.shrct.businessprocess.customerservice.impl.RCFaultReportImpl as e   where ((((e.status) <> (:rmaState)) and ((e.status) <> (:pendingState))) and ((e.status) <> (:finishState))) and  e.active = 1      ").setParameter("rmaState",rmaState).setParameter("pendingState",pendingState).setParameter("finishState",finishState);
    Collection<RCFaultReport> _list = query.list();
    final Procedure1<RCFaultReport> _function = new Procedure1<RCFaultReport>() {
        public void apply(final RCFaultReport it) {
          it.updateCurrentLevel();
        }
      };
    IterableExtensions.<RCFaultReport>forEach(_list, _function);
  }
}
